package com.tjsinfo.tjsoa.articles.vo;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import com.tjsinfo.tjsoa.common.DayFormat;
import com.tjsinfo.tjsoa.system.vo.TSystemUser;
/**
 * TIndexArticlesId entity.
 * 
 * @author MyEclipse Persistence Tools
 */

public class TIndexArticles implements java.io.Serializable {

	// Fields

	private Integer id;
	private String url;
	private Integer userId;
	private String createDate;
	private String availableDate;
	private Integer showOrder;
	private String isFile;
	private String uploadFile;
	private String uuid;
	private String title;
	private String shortTitle;
	private String keyWord;
	private String author;
	private String smallPic;
	private String smallContent;
	private String mainContent;
	private Integer cid;
	private String userName;
//	private TSystemUser TSystemUser;
	// Constructors

	/** default constructor */
	public TIndexArticles() {
	}

	/** minimal constructor */
	public TIndexArticles(Integer id) {
		this.id = id;
	}

	/** full constructor */
	public TIndexArticles(Integer id, String url, Integer userId, 
			String createDate, String availableDate, Integer showOrder,
			String isFile, String uploadFile, String uuid, String title,
			String shortTitle, String keyWord, String author, String smallPic,
			String smallContent, String mainContent, Integer cid, String userName) {
		this.id = id;
		this.url = url;
		this.userId = userId;
		this.createDate = createDate;
		this.availableDate = availableDate;
		this.showOrder = showOrder;
		this.isFile = isFile;
		this.uploadFile = uploadFile;
		this.uuid = uuid;
		this.title = title;
		this.shortTitle = shortTitle;
		this.keyWord = keyWord;
		this.author = author;
		this.smallPic = smallPic;
		this.smallContent = smallContent;
		this.mainContent = mainContent;
		this.cid = cid;
		this.userName=userName;
//		this.TSystemUser = TSystemUser;
	}

	// Property accessors

	public Integer getId() {
		return this.id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	public String getUrl() {
		return this.url;
	}

	public void setUrl(String url) {
		this.url = url;
	}

	public Integer getUserId() {
		return this.userId;
	}

	public void setUserId(Integer userId) {
		this.userId = userId;
	}

	public String getCreateDate() {
		return this.createDate;
	}

	public void setCreateDate(String createDate) {
		this.createDate = createDate;
	}

	public String getAvailableDate() {
		return this.availableDate;
	}

	public void setAvailableDate(String availableDate) {
		this.availableDate = availableDate;
	}

	public Integer getShowOrder() {
		return this.showOrder;
	}

	public void setShowOrder(Integer showOrder) {
		this.showOrder = showOrder;
	}

	public String getIsFile() {
		return this.isFile;
	}

	public void setIsFile(String isFile) {
		this.isFile = isFile;
	}

	public String getUploadFile() {
		return this.uploadFile;
	}

	public void setUploadFile(String uploadFile) {
		this.uploadFile = uploadFile;
	}

	public String getUuid() {
		return this.uuid;
	}

	public void setUuid(String uuid) {
		this.uuid = uuid;
	}

	public String getTitle() {
		return this.title;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	public String getShortTitle() {
		return this.shortTitle;
	}

	public void setShortTitle(String shortTitle) {
		this.shortTitle = shortTitle;
	}

	public String getKeyWord() {
		return this.keyWord;
	}

	public void setKeyWord(String keyWord) {
		this.keyWord = keyWord;
	}

	public String getAuthor() {
		return this.author;
	}

	public void setAuthor(String author) {
		this.author = author;
	}

	public String getSmallPic() {
		return this.smallPic;
	}

	public void setSmallPic(String smallPic) {
		this.smallPic = smallPic;
	}

	public String getSmallContent() {
		return this.smallContent;
	}

	public void setSmallContent(String smallContent) {
		this.smallContent = smallContent;
	}

	public String getMainContent() {
		return this.mainContent;
	}

	public void setMainContent(String mainContent) {
		this.mainContent = mainContent;
	}
	
	public Integer getCid() {
		return this.cid;
	}

	public void setCid(Integer cid) {
		this.cid = cid;
	}
	
	public String getUserName() {
		return userName;
	}

	public void setUserName(String userName) {
		this.userName = userName;
	}	
//	public TSystemUser getTSystemUser() {
//		return TSystemUser;
//	}
//
//	public void setTSystemUser(TSystemUser systemUser) {
//		this.TSystemUser = systemUser;
//	}
	
	/*
	 * 如果文章标题短于length，则在标题后面加上副标题返回
	 */
	public String getTitleLong(int length) {
		String strTitleLong="";
		if (this.getShortTitle()==null || this.getTitle().length()>=length) {
			strTitleLong=this.getTitle().replace("<br/>","");
		}else{
			strTitleLong=this.getTitle().replace("<br/>","")+this.getShortTitle().replace("<br/>","");
	    }
		return strTitleLong;
	}
	
	/*
	 * 如果文章更新时间在3天以内，则在标题后面加上new图片
	 */
	public int getTitleDate(String Title, String createDate) {
		int len=0;
		Calendar c = Calendar.getInstance();	
		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); 
		String date = sdf.format(c.getTime());
		    Date d = null;
		    Date dd = null;
			try {
				d = sdf.parse(date);
				dd = sdf.parse(createDate); 
			} catch (ParseException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
	        int day = c.get(Calendar.DATE);
	        int Day = dd.getDay();
	        int datacha;
	        
	    datacha=(int)DayFormat.dateDiff("day",d,dd);    
		return datacha;
	}
	
	
	public boolean equals(Object other) {
		if ((this == other))
			return true;
		if ((other == null))
			return false;
		if (!(other instanceof TIndexArticles))
			return false;
		TIndexArticles castOther = (TIndexArticles) other;

		return ((this.getId() == castOther.getId()) || (this.getId() != null
				&& castOther.getId() != null && this.getId().equals(
				castOther.getId())))
				&& ((this.getUrl() == castOther.getUrl()) || (this.getUrl() != null
						&& castOther.getUrl() != null && this.getUrl().equals(
						castOther.getUrl())))
				&& ((this.getUserId() == castOther.getUserId()) || (this
						.getUserId() != null
						&& castOther.getUserId() != null && this.getUserId()
						.equals(castOther.getUserId())))
				&& ((this.getCreateDate() == castOther.getCreateDate()) || (this
						.getCreateDate() != null
						&& castOther.getCreateDate() != null && this
						.getCreateDate().equals(castOther.getCreateDate())))
				&& ((this.getAvailableDate() == castOther.getAvailableDate()) || (this
						.getAvailableDate() != null
						&& castOther.getAvailableDate() != null && this
						.getAvailableDate()
						.equals(castOther.getAvailableDate())))
				&& ((this.getShowOrder() == castOther.getShowOrder()) || (this
						.getShowOrder() != null
						&& castOther.getShowOrder() != null && this
						.getShowOrder().equals(castOther.getShowOrder())))
				&& ((this.getIsFile() == castOther.getIsFile()) || (this
						.getIsFile() != null
						&& castOther.getIsFile() != null && this.getIsFile()
						.equals(castOther.getIsFile())))
				&& ((this.getUploadFile() == castOther.getUploadFile()) || (this
						.getUploadFile() != null
						&& castOther.getUploadFile() != null && this
						.getUploadFile().equals(castOther.getUploadFile())))
				&& ((this.getUuid() == castOther.getUuid()) || (this.getUuid() != null
						&& castOther.getUuid() != null && this.getUuid()
						.equals(castOther.getUuid())))
				&& ((this.getTitle() == castOther.getTitle()) || (this
						.getTitle() != null
						&& castOther.getTitle() != null && this.getTitle()
						.equals(castOther.getTitle())))
				&& ((this.getShortTitle() == castOther.getShortTitle()) || (this
						.getShortTitle() != null
						&& castOther.getShortTitle() != null && this
						.getShortTitle().equals(castOther.getShortTitle())))
				&& ((this.getKeyWord() == castOther.getKeyWord()) || (this
						.getKeyWord() != null
						&& castOther.getKeyWord() != null && this
						.getKeyWord().equals(castOther.getKeyWord())))
				&& ((this.getAuthor() == castOther.getAuthor()) || (this
						.getAuthor() != null
						&& castOther.getAuthor() != null && this.getAuthor()
						.equals(castOther.getAuthor())))
				&& ((this.getSmallPic() == castOther.getSmallPic()) || (this
						.getSmallPic() != null
						&& castOther.getSmallPic() != null && this
						.getSmallPic().equals(castOther.getSmallPic())))
				&& ((this.getSmallContent() == castOther.getSmallContent()) || (this
						.getSmallContent() != null
						&& castOther.getSmallContent() != null && this
						.getSmallContent().equals(castOther.getSmallContent())))
				&& ((this.getMainContent() == castOther.getMainContent()) || (this
						.getMainContent() != null
						&& castOther.getMainContent() != null && this
						.getMainContent().equals(castOther.getMainContent())))
				&& ((this.getCid() == castOther.getCid()) || (this
						.getCid() != null
						&& castOther.getCid() != null && this
						.getCid().equals(castOther.getCid())))
				&& ((this.getUserName() == castOther.getUserName()) || (this
						.getUserName() != null
						&& castOther.getUserName() != null && this
						.getUserName().equals(castOther.getUserName())))
//				&& ((this.getTSystemUser() == castOther.getTSystemUser()) || (this
//						.getTSystemUser() != null
//						&& castOther.getTSystemUser() != null && this
//						.getTSystemUser().equals(castOther.getTSystemUser())))
;
	}

	public int hashCode() {
		int result = 17;

		result = 37 * result + (getId() == null ? 0 : this.getId().hashCode());
		result = 37 * result
				+ (getUrl() == null ? 0 : this.getUrl().hashCode());
		result = 37 * result
				+ (getUserId() == null ? 0 : this.getUserId().hashCode());
		result = 37 * result
				+ (getCreateDate() == null ? 0 : this.getCreateDate().hashCode());
		result = 37
				* result
				+ (getAvailableDate() == null ? 0 : this.getAvailableDate()
						.hashCode());
		result = 37 * result
				+ (getShowOrder() == null ? 0 : this.getShowOrder().hashCode());
		result = 37 * result
				+ (getIsFile() == null ? 0 : this.getIsFile().hashCode());
		result = 37
				* result
				+ (getUploadFile() == null ? 0 : this.getUploadFile()
						.hashCode());
		result = 37 * result
				+ (getUuid() == null ? 0 : this.getUuid().hashCode());
		result = 37 * result
				+ (getTitle() == null ? 0 : this.getTitle().hashCode());
		result = 37
				* result
				+ (getShortTitle() == null ? 0 : this.getShortTitle()
						.hashCode());
		result = 37 * result
				+ (getKeyWord() == null ? 0 : this.getKeyWord().hashCode());
		result = 37 * result
				+ (getAuthor() == null ? 0 : this.getAuthor().hashCode());
		result = 37 * result
				+ (getSmallPic() == null ? 0 : this.getSmallPic().hashCode());
		result = 37
				* result
				+ (getSmallContent() == null ? 0 : this.getSmallContent()
						.hashCode());
		result = 37
				* result
				+ (getMainContent() == null ? 0 : this.getMainContent()
						.hashCode());
		result = 37
				* result
				+ (getCid() == null ? 0 : this.getCid()
						.hashCode());		
		result = 37
				* result
				+ (getUserName() == null ? 0 : this.getUserName()
						.hashCode());				
//		result = 37
//				* result
//				+ (getTSystemUser() == null ? 0 : this.getTSystemUser()
//						.hashCode());		
		return result;
	}



}